<template>
  <div class="dialog">
    <el-dialog
      title="转分塘详情"
      :visible.sync="showDialog"
      width="65%"
      top="0"
      :close-on-click-modal="false"
      @close="cancel"
    >

      <el-row :gutter="15">
        <el-table
          ref="rightTableData"
          :data="rightTableData"
          tooltip-effect="dark"
          highlight-current-row
          border
          stripe
          class="rightTableData"
        >
          <el-table-column type="index" label="序号" width="50" />
          <el-table-column label="转入鱼类型" prop="fishTypeStr" align="center" min-width="120" >
          </el-table-column>
          <el-table-column label="规格" prop="specName" align="center" min-width="120" >
          </el-table-column>
          <el-table-column label="转入数量" prop="num" min-width="95" >
          </el-table-column>
          <!-- <el-table-column label="转入重量" prop="weight" min-width="95"></el-table-column> -->
          <el-table-column label="转入重量" min-width="95">
            <template slot-scope="scope">
              {{scope.row.weight}}斤
            </template>
          </el-table-column>
          <!-- <el-table-column label="操作" min-width="80">
            <template slot-scope="scope">
              <el-button
                v-if="nowChanceStau === 'edit'"
                type="text"
                style="color:red;text-decoration: underline;"
                size="small"
                @click.native.prevent="editRow(scope.$index,scope.row)"
              >提交修改</el-button>
              <el-button
                v-if="nowChanceStau === 'add'"
                type="text"
                style="color:red;text-decoration: underline;"
                size="small"
                @click.native.prevent="deleteRow(scope.$index, rightTableData)"
              >删除</el-button>
            </template>
          </el-table-column> -->
          <template slot="empty">
            <div>暂无数据</div>
          </template>
        </el-table>
      </el-row>
      <!-- <div slot="footer" class="dialog-footer">
        <el-button class="cancelbtn" @click="cancel()">取 消</el-button>
        <el-button type="primary" class="savebtn" @click="save('ruleForm')">保 存</el-button>
      </div> -->
    </el-dialog>
  </div>
</template>

<script>
import TransferSeparatePondApi from "@/api/batch-mange/transfer-separate-pond"
import { mapGetters } from "vuex";
import { mymixin } from "@/utils/mixin";
export default {
  name: "",
  components: {},
  mixins: [mymixin],
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    completeInfoObject: {
      type: [Object],
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      rightTableData:[],
      specificationList:[],
      currentBatchId:1,
      showDialog:this.show
    };
  },
  computed: {
    ...mapGetters({
      judgePermission: "permission/judgePermission",
    }),
  },
  watch: {
    show(v) {
      this.showDialog = v;
    },
    completeInfoObject(v) {
      this.queryTransferDetail(v.transferSeparatePondId)
    },
  },
  created() {},
  mounted() {
  },
  methods: {
    queryTransferDetail(e){
      TransferSeparatePondApi.queryByTransferSeparatePondId({transferSeparatePondId:e}).then(res=>{
        this.rightTableData = res.data
      })
    },
    // 修改一行数据
    editRow(index, rows){
      let params = {
        inputPondDetailId:rows.inputPondDetailId,
        specificationId:rows.specificationId,
        inputNum:rows.inputNum,
        inputWeight:rows.inputWeight,
      }
      TransferSeparatePondApi.edit(params).then(res=>{
        if (res.success === true) {
          this.$message.success("修改成功！");
        } else {
          this.$message.error(res.message);
        }
      })
    },
    // 删除一行数据
    deleteRow(index, rows) {
      console.log(index, rows);
      this.$confirm("此操作将永久删除该项, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        
      }).then(() => {
        let params = {
          id:rows.inputPondDetailId,
        }
        TransferSeparatePondApi.delById(params).then(res=>{
          if (res.success === true) {
            this.$message.success("删除成功！");
            this.rightTableData.splice(index, 1);
          } else {
            this.$message.error(res.message);
          }
        })
      }).catch(() => {
        this.$message({
          type: "info",
          message: "已取消删除"
        });
      });
    },
    changeCurrentPage(currentPage) {
      this.currentPage = currentPage;
      this.queryPageList();
    },
    close() {
      this.$emit("closeDialog");
    },
    cancel() {
      this.$emit("cancelDialog");
    },
  },
};
</script>

<style lang="scss" scoped>
.pagination {
  position: absolute;
  right: 0px;
  bottom: -40px;
}
  .el-table{
    position: relative;
  }
  ::v-deep .el-dialog__body{
    padding: 30px 20px 50px 20px;
  }
</style>
